<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage"
     >
    </ex_super_table_page>
  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';
import emitOnFunction from '@/mixin/emit-on-function';

import page_table_model_manage from '@/mixin/page_table_model_manage';
let emitKey = 'appointment>confirm'
import router_params from '@/mixin/router_params';
export default {
  title: 'title_appointment_report_list',
  mixins: [router_params,superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],

  data() {
    return {
      selection: [],
      option: {
        actionExtra: [
          { label: '导出', attrs: { type: "primary" }, click: this.exportExcel },
        ],
        table: {
          url: "/oms-api/order/OmsInboundScheduleRpc/selectPage.json",
          // urlDataHandle: this.dataHandle,
          urlParams: (params) => { return Object.assign({ warehouseId: this.$route.query.warehouseId,expectedDate:this.$route.query.expectedDate }, params) },
          model: this.option_table_model(),
        },
      },
    };
  },
  methods: {
    init_data_default(into_params){
      this.$emit("tagModifyLabel", { _key: 'label_name_code', name: this.$tt('title_appointment_report_list'), code: into_params.warehouseId || '' })


    },
    option_table_model() {
      return [
        { type: 'selection', clickToggle: true, keyGroup: 'label_table_operate' },
        { key: 'transitNo', label: '运单编号',width: 100,'show-overflow-tooltip': true},
        { key: 'customerName', label: '客户名称',minWidth: 100,'show-overflow-tooltip': true},
        { key: 'scheduleTypeEnum', label: '预约方式',minWidth: 100,'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "ScheduleTypeEnum")
        },
        { key: 'scheduleStatusEnum', label: '预约状态',minWidth: 100,'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "ScheduleStatusEnum")
        },
        { key: 'expectedDate', label: '预计到仓时间',minWidth: 160,'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$dateFormat(v)
        },
        { key: 'expectPackagingQty', label: '申报包数',minWidth: 160,'show-overflow-tooltip': true},
        { key: 'expectBoxQty', label: '申报箱数',minWidth: 160,'show-overflow-tooltip': true},
        { key: 'vehicleNo', label: '车牌号码',minWidth: 100,'show-overflow-tooltip': true},
        { key: 'driverName', label: '司机姓名',minWidth: 120,'show-overflow-tooltip': true},
        { key: 'driverPhone', label: '司机电话',minWidth: 100,'show-overflow-tooltip': true},
        { key: 'volumn', label: '申报货物体积',minWidth: 120,'show-overflow-tooltip': true},
        { key: 'weight', label: '申报货物重量',minWidth: 120,'show-overflow-tooltip': true},
        { key: 'reporter', label: '申报人',minWidth: 160,'show-overflow-tooltip': true},
        { key: 'gmtCreate', label: '预约申报时间',minWidth: 100,'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$dateFormat(v)
        },
        { label: '关联入库单号',minWidth: 100,'show-overflow-tooltip': true,
          render(h, { row }){
              return (
                <div>
                  {
                    row.omsInboundScheduleDetailList.map((item,index)=>{
                      return(
                        <span>
                          <span>{item.receivingOrderCode}</span>
                          {row.omsInboundScheduleDetailList.length>index+1?<span>,</span>:null}
                        </span>
                       )
                    })
                  }
                </div>
              )
            }
        },
        { key: 'isDiff', label: '是否差异',minWidth: 100,'show-overflow-tooltip': true,
          formatter: (r,c,v) => this.$enumShow(v, "YesOrNoEnum"),
        },
        {
          type: 'operate',
          width: 160,
          fixed:"right",
          operate: [
            // {
            //   label: "导出",
            //   click: (row, i) => {}
            // },
            {
              label: "title_appointment_report_detail",
              click: (row, i) => {
                this.$router.push({
                  path: './appointment_report_detail', query: { id: row.id, }
                })
              }
            },
          ]
        }
      ]
    },
    exportExcel() {
      const params = this.$refs.SuperTablePage.getSearchFormData()

      const scheduleIds = []
      this.selection.forEach(item=>{
        scheduleIds.push(item.id)
      })
      this.$downloadFile({
        url:'/oms-api/order/OmsInboundScheduleRpc/exportExcelAdmin.json',
        window:true,
        data:{
          ...params,
          scheduleIds:scheduleIds.toString()
        }
      })
    },
    dataHandle(res) {
      return [{omsInboundScheduleDetailList:[{receivingOrderCode:666},{receivingOrderCode:777}]}]
    },
  }
};

</script>
<style></style>
